home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieDVDEmpire.py < prev    next >
Text File  |  2008-11-17  |  7KB  |  179 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieDVDEmpire.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2007
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import re
  27.  
  28. plugin_name = "DVD Empire"
  29. plugin_description = "International Retailer of DVD Movies"
  30. plugin_url = "www.dvdempire.com"
  31. plugin_language = _("English")
  32. plugin_author = "Michael Jahn"
  33. plugin_author_email = "<mikej06@hotmail.com>"
  34. plugin_version = "1.1"
  35.  
  36. class Plugin(movie.Movie):
  37.     def __init__(self, id):
  38.         self.encode='iso-8859-1'
  39.         self.movie_id = id
  40.         self.url = "http://www.dvdempire.com/Exec/v4_item.asp?item_id=" + str(self.movie_id)
  41.     
  42.     def get_image(self):
  43.         tmp_page = gutils.trim(self.page, '<td align="center" valign="top" class="fontsmall">', '</td>')
  44.         self.image_url = gutils.trim(tmp_page, '<img src=\'', '\' ')
  45.  
  46.     def get_o_title(self):
  47.         self.o_title = gutils.strip_tags(gutils.trim(self.page,'<td class="fontxlarge" valign="top" align="left">', '<nobr>'))
  48.  
  49.     def get_title(self):
  50.         self.title = gutils.strip_tags(gutils.trim(self.page,'<td class="fontxlarge" valign="top" align="left">', '<nobr>'))
  51.  
  52.     def get_director(self):
  53.         self.director = gutils.strip_tags(gutils.trim(self.page,">Directors:","</a>"))
  54.         self.director = self.director.replace(' ', '')
  55.         self.director = self.director.replace('•', '')
  56.  
  57.     def get_plot(self):
  58.         self.plot = gutils.strip_tags(gutils.trim(self.page, '<td width="100%" valign="top" class="fontsmall3">', '</td>'))
  59.         self.plot = self.plot.replace('\x93', '"')
  60.  
  61.     def get_year(self):
  62.         self.year = gutils.strip_tags(gutils.trim(self.page, '>Production Year:', '<br />'))
  63.  
  64.     def get_runtime(self):
  65.         self.runtime = gutils.strip_tags(gutils.trim(self.page, '>Length:', '<br />'))
  66.  
  67.     def get_genre(self):
  68.         self.genre = gutils.strip_tags(gutils.trim(self.page, '>Genre</b>:', '</tr>'))
  69.  
  70.     def get_cast(self):
  71.         self.cast = gutils.trim(self.page, '>Actors:', '</td><td')
  72.         self.cast = self.cast.replace('<br>', '\n')
  73.         self.cast = self.cast.replace('<br />', '\n')
  74.         self.cast = self.cast.replace(' ', '')
  75.         self.cast = self.cast.replace('•', '')
  76.         self.cast = self.cast.replace('•', '')
  77.         self.cast = gutils.strip_tags(self.cast)
  78.  
  79.     def get_classification(self):
  80.         self.classification = gutils.strip_tags(gutils.trim(self.page, '>Rating:', '<br />'))
  81.  
  82.     def get_studio(self):
  83.         self.studio = gutils.strip_tags(gutils.trim(self.page, '>Studio:', '<br />'))
  84.  
  85.     def get_o_site(self):
  86.         self.o_site = ""
  87.  
  88.     def get_site(self):
  89.         self.site = self.url
  90.  
  91.     def get_trailer(self):
  92.         self.trailer = ""
  93.  
  94.     def get_country(self):
  95.         self.country = ""
  96.  
  97.     def get_rating(self):
  98.         self.rating = gutils.clean(gutils.trim(self.page, '>Overall Rating:', ' out of'))
  99.         try:
  100.             tmp_float = float(self.rating)
  101.             tmp_float = round(2 * tmp_float, 0)
  102.             self.rating = str(tmp_float)
  103.         except:
  104.             self.rating = '0'
  105.  
  106.     def get_notes(self):
  107.         self.notes = ''
  108.         tmp_page = gutils.trim(self.page, 'Features:', '<b>')
  109.         tmp_page = tmp_page.replace('<br>', '\n')
  110.         tmp_page = tmp_page.replace('<br />', '\n')
  111.         tmp_page = gutils.strip_tags(tmp_page)
  112.         if tmp_page <> '':
  113.             self.notes = self.notes + '\nFeatures:' + tmp_page + '\n'
  114.         tmp_page = gutils.trim(self.page, 'Video:', '<b>')
  115.         tmp_page = tmp_page.replace('<br>', '\n')
  116.         tmp_page = tmp_page.replace('<br />', '\n')
  117.         tmp_page = gutils.strip_tags(tmp_page)
  118.         if tmp_page <> '':
  119.             self.notes = self.notes + '\nVideo:' + tmp_page + '\n'
  120.         tmp_page = gutils.trim(self.page, 'Audio:', '<b>')
  121.         tmp_page = tmp_page.replace('<br>', '\n')
  122.         tmp_page = tmp_page.replace('<br />', '\n')
  123.         tmp_page = gutils.strip_tags(tmp_page)
  124.         if tmp_page <> '':
  125.             self.notes = self.notes + '\nAudio:' + tmp_page
  126.         tmp_page = gutils.trim(self.page, 'Subtitles:', '<b>')
  127.         tmp_page = gutils.strip_tags(tmp_page)
  128.         if tmp_page <> '':
  129.             self.notes = self.notes + '\nSubtitles:\n' + tmp_page + '\n'
  130.  
  131. class SearchPlugin(movie.SearchMovie):
  132.     def __init__(self):
  133.         self.original_url_search   = "http://www.dvdempire.com/Exec/v1_search_all.asp?&site_media_id=0&pp=&search_refined=32&used=0&string="
  134.         self.translated_url_search = "http://www.dvdempire.com/Exec/v1_search_all.asp?&site_media_id=0&pp=&search_refined=32&used=0&string="
  135.         self.encode = 'iso-8859-1'
  136.  
  137.     def search(self,parent_window):
  138.         self.open_search(parent_window)
  139.         # short the content
  140.         tmp_page = gutils.trim(self.page,'<select name="sort"', 'Click Here to make a Suggestion</a>')
  141.         #
  142.         # try to get all result pages (not so nice, but it works)
  143.         #
  144.         tmp_pagecount = gutils.trim(self.page, '<div id="Search_Container" name="Search_Container">', '</table>')
  145.         tmp_pagecountintuse = 1
  146.         elements = tmp_pagecount.split("&page=")
  147.         for element in elements:
  148.             try:
  149.                 tmp_pagecountint = int(gutils.before(element, '\''))
  150.             except:
  151.                 tmp_pagecountint = 0
  152.             if tmp_pagecountint > tmp_pagecountintuse:
  153.                 tmp_pagecountintuse = tmp_pagecountint
  154.         tmp_pagecountintcurrent = 1
  155.         while tmp_pagecountintuse > tmp_pagecountintcurrent and tmp_pagecountintuse < 4:
  156.             tmp_pagecountintcurrent = tmp_pagecountintcurrent + 1
  157.             self.url = "http://www.dvdempire.com/Exec/v1_search_all.asp?&site_media_id=0&pp=&search_refined=32&used=0&page=" + str(tmp_pagecountintcurrent) + "&string="
  158.             self.open_search(parent_window)
  159.             tmp_page2 = gutils.trim(self.page,'<select name="sort"', 'Click Here to make a Suggestion</a>')
  160.             tmp_page = tmp_page + tmp_page2
  161.  
  162.         self.page = tmp_page
  163.         return self.page
  164.  
  165.     def get_searches(self):
  166.         split_pattern = re.compile('<a[\t ]+href=["\']/Exec/v4_item[.]asp[?]userid=[-0-9]+[&]amp;item_id=')
  167.         check_pattern = re.compile('[0-9]+[&]amp;searchID=[0-9]+["\']>')
  168.         elements = split_pattern.split(self.page)
  169.         elements[0] = ''
  170.         for element in elements:
  171.             if element <> '':
  172.                 is_an_item = check_pattern.search(element)
  173.                 if is_an_item:
  174.                     tmp_title = gutils.strip_tags(gutils.trim(element, ">", "</a>"))
  175.                     if tmp_title <> '':
  176.                         tmp_id = gutils.before(element,'&')
  177.                         self.ids.append(tmp_id)
  178.                         self.titles.append(tmp_title)
  179.